package com.nbjtjc.safe.bean.runnable;

import com.nbjtjc.safe.service.know.SafeKnowledgeService;
import com.nbjtjc.safe.service.know.SafeLabelService;

import java.util.concurrent.Callable;

/**
 * @auther guqianbin
 * @date 2018/8/6 14:34
 **/
public class InitKnowledgeRunnable implements Callable<Boolean> {
    private SafeLabelService safeLabelService;
    private SafeKnowledgeService safeKnowledgeService;
    private int fromCompanyId=0;
    private int toCompanyId=0;
    public InitKnowledgeRunnable() {
    }

    public InitKnowledgeRunnable(SafeLabelService safeLabelService
            , SafeKnowledgeService safeKnowledgeService, int fromCompanyId, int toCompanyId) {
        this.safeLabelService = safeLabelService;
        this.safeKnowledgeService = safeKnowledgeService;
        this.fromCompanyId = fromCompanyId;
        this.toCompanyId = toCompanyId;
    }

    public InitKnowledgeRunnable(SafeLabelService safeLabelService
            , SafeKnowledgeService safeKnowledgeService) {
        this.safeLabelService = safeLabelService;
        this.safeKnowledgeService = safeKnowledgeService;
    }

    @Override
    public Boolean call() throws Exception {
        if(!safeLabelService.copySafeLabel(fromCompanyId,toCompanyId)){
            return false;
        }
        if(!safeKnowledgeService.copyKnowledge(fromCompanyId,toCompanyId)){
            return false;
        }
        return true;
    }
}
